package ch.ebnoether.controller;

import ch.ebnoether.gui.WinnerCardRight;
import ch.ebnoether.gui.YatzyGUI;
import ch.ebnoether.wuerfel.Dice;

import javax.swing.*;
import java.awt.event.MouseEvent;

public class DreierPaschController extends MasterController {

  private Dice[] dices;
  private WinnerCardRight rechts;

  /**
   * @param dices
   * @param rechts
   */
  public DreierPaschController(Dice[] dices, WinnerCardRight rechts, YatzyGUI yatzi) {
    super(dices, yatzi);
    this.dices = dices;
    this.rechts = rechts;
  }

  /*
     * (non-Javadoc)
     *
     * @see
     * ch.ebnoether.controller.Controller#mouseClicked(java.awt.event.MouseEvent
     * )
     */
  @Override
  public void mouseClicked(MouseEvent e) {
    Object o = e.getSource();
    JTextField t = (JTextField) o;

    if (!super.isGesetzt() && MasterController.setzbar) {

      t.setText("" + ControllerLogik.paschBerechnen(this.dices, 3));
      ControllerLogik.setTotalRechts(this.rechts, Integer.valueOf(t.getText()));
      super.mouseClicked(e);
    }
  }

  /*
     * (non-Javadoc)
     *
     * @see
     * ch.ebnoether.controller.Controller#mouseEntered(java.awt.event.MouseEvent
     * )
     */
  @Override
  public void mouseEntered(MouseEvent e) {
    Object o = e.getSource();
    JTextField t = (JTextField) o;

    if (!super.isGesetzt() && MasterController.setzbar) {

      t.setText("" + ControllerLogik.paschBerechnen(this.dices, 3));
    }
  }
}
